home *** CD-ROM | disk | FTP | other *** search
/ Introduction to 3D Game …ogramming with DirectX 12 / Introduction-to-3D-Game-Programming-with-DirectX-12.ISO / Code.Textures / Chapter 20 Shadow Mapping / Shadows / ShadowMap.h < prev    next >
Encoding:
C/C++ Source or Header  |  2016-03-02  |  1.4 KB  |  57 lines

  1. //***************************************************************************************
  2. // ShadowMap.h by Frank Luna (C) 2015 All Rights Reserved.
  3. //***************************************************************************************
  4.  
  5. #pragma once
  6.  
  7. #include "../../Common/d3dUtil.h"
  8.  
  9. class ShadowMap
  10. {
  11. public:
  12.     ShadowMap(ID3D12Device* device,
  13.         UINT width, UINT height);
  14.         
  15.     ShadowMap(const ShadowMap& rhs)=delete;
  16.     ShadowMap& operator=(const ShadowMap& rhs)=delete;
  17.     ~ShadowMap()=default;
  18.  
  19.     UINT Width()const;
  20.     UINT Height()const;
  21.     ID3D12Resource* Resource();
  22.     CD3DX12_GPU_DESCRIPTOR_HANDLE Srv()const;
  23.     CD3DX12_CPU_DESCRIPTOR_HANDLE Dsv()const;
  24.  
  25.     D3D12_VIEWPORT Viewport()const;
  26.     D3D12_RECT ScissorRect()const;
  27.  
  28.     void BuildDescriptors(
  29.         CD3DX12_CPU_DESCRIPTOR_HANDLE hCpuSrv,
  30.         CD3DX12_GPU_DESCRIPTOR_HANDLE hGpuSrv,
  31.         CD3DX12_CPU_DESCRIPTOR_HANDLE hCpuDsv);
  32.  
  33.     void OnResize(UINT newWidth, UINT newHeight);
  34.  
  35. private:
  36.     void BuildDescriptors();
  37.     void BuildResource();
  38.  
  39. private:
  40.  
  41.     ID3D12Device* md3dDevice = nullptr;
  42.  
  43.     D3D12_VIEWPORT mViewport;
  44.     D3D12_RECT mScissorRect;
  45.  
  46.     UINT mWidth = 0;
  47.     UINT mHeight = 0;
  48.     DXGI_FORMAT mFormat = DXGI_FORMAT_R24G8_TYPELESS;
  49.  
  50.     CD3DX12_CPU_DESCRIPTOR_HANDLE mhCpuSrv;
  51.     CD3DX12_GPU_DESCRIPTOR_HANDLE mhGpuSrv;
  52.     CD3DX12_CPU_DESCRIPTOR_HANDLE mhCpuDsv;
  53.  
  54.     Microsoft::WRL::ComPtr<ID3D12Resource> mShadowMap = nullptr;
  55. };
  56.  
  57.